package easy;

import util.PrintUtils;

public class Solution_922 {
    public int[] sortArrayByParityII(int[] nums) {
        int[] ints = new int[nums.length];
        for (int i = 0, a = 0, b = 1; i < nums.length; i++) {
            if (nums[i] % 2 == 0) {
                ints[a] = nums[i];
                a += 2;
            } else {
                ints[b] = nums[i];
                b += 2;
            }
        }
        return ints;
    }

    public static void main(String[] args) {
        Solution_922 model = new Solution_922();
        PrintUtils.arrayInt(model.sortArrayByParityII(new int[]{4, 2, 5, 7}));
    }
}
